package predictor;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.*;

import types.Movie;
import youtube.Search;
import youtube.Youtube;

public class Main {
public static void main(String[] args) throws Exception {
	List<Movie> movies = new ArrayList<Movie>();
	TreeSet<String> studios = new TreeSet<String>();
	File file = new File("movie-check");
	FileInputStream in = new FileInputStream(file);
	BufferedReader reader = new BufferedReader(new InputStreamReader(in, "UTF-8"));
	String line;
	BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream("movie-final", true), "UTF-8"));
	while ((line = reader.readLine()) != null) {
		Movie movie = new Movie().generateFrom(line);
		movies.add(movie);
		writer.write(movie.toString() + Youtube.getInfo(Search.getUrl(movie.getTitle())) + "\n");
		writer.flush();
	}
	writer.close();
	reader.close();
	System.out.println(movies.size());
}
}
